
var form_validation = function() {
    var e = function() {
            jQuery(".form-valide").validate({
                ignore: [],
                errorClass: "invalid-feedback animated fadeInDown",
                errorElement: "div",
                errorPlacement: function(e, a) {
                    jQuery(a).parents(".form-group > div").append(e)
                },
                highlight: function(e) {
                    jQuery(e).closest(".form-group").removeClass("is-invalid").addClass("is-invalid")
                },
                success: function(e) {
                    jQuery(e).closest(".form-group").removeClass("is-invalid"), jQuery(e).remove()
                },
                rules: {
                    "val-username": {
                        required: !0,
                        minlength: 3
                        
                    },
                    "val-email": {
                        required: !0,
                        minlength: 6,
                       	email: true
                    },
                    "val-phone": {
                        required:true,
                        digits:true,
                        rangelength:[11,11]
                               
                    },
                    "val-select2": {
                        required: !0
                    },
                    "val-select2-multiple": {
                        required: !0,
                        minlength: 2
                    },
                    "val-suggestions": {
                        required: !0,
                    },
                    "val-skill": {
                        
                    },
                    "val-currency": {
                        required: true,
                        digits:true,
                        rangelength: [18,18]
                        
                    },
                    "val-website": {
                        required: !0,
                        url: !0
                    },
                    "val-phoneus": {
                        required: !0,
                        phoneUS: !0
                    },
                    "val-digits": {
                        required: !0,
                    },
                    "val-number": {
                        required: !0,
                    },
                    "val-range": {
                        required: !0,
                        range: [1, 5]
                    },
                    "val-terms": {
                        required: !0
                    }
                    
                },
                messages: {
                    "val-username": {
                        required: "用户名不能为空",
                        minlength: "长度至少为3位"
                    },
                    "val-email": {
                    	required:"邮箱不能为空",
                    	minlength: "长度至少为6位",
                    	email:"请输入有效的电子邮件地址"
                    
                  },
                    "val-phone": {
                        required: "手机号不能为空",
                       	rangelength: "长度为11位",
                       	digits: "请输入正确的手机号码"
                    },
                      "val-currency":{
                      	 required: "身份证号不能为空",
                         rangelength:"长度为18位",
                         digits: "请输入正确的身份证号"
                    },
                    "val-select2": "Please select a value!",
                    "val-select2-multiple": "Please select at least 2 values!",
                    "val-suggestions": "地址不能为空",
                    "val-website": "家属联系方式不能为空",
                    "val-phoneus": "Please enter a US phone!",
                    "val-digits": "职位不能为空",
                    "val-number": "公司不能为空",
                    "val-range": "Please enter a number between 1 and 5!",
                    "val-terms": "字段不能为空"
                }
            })
        }
    return {
        init: function() {
            e(), a(), jQuery(".js-select2").on("change", function() {
                jQuery(this).valid()
            })
        }
    }
}();
jQuery(function() {
    form_validation.init()
});